package com.Maykk.systemIO;

import java.util.Scanner;

/**
 * @ClassName: Demo03
 * @Description: TODO Scanner 匿名对象类问题解决
 * @Author: MaykkStar@163.com
 */
public class Demo03 {

    public static void main(String[] args) {
        String name;
        int age;
        String sex;
        float score;

        // Scanner sc = new Scanner(System.in);
        // System.out.println("请输入姓名：");
        // name = sc.nextLine();
        // System.out.println("请输入年龄：");
        // age = sc.nextInt();
        // System.out.println("请输入性别：");
        // sex = sc.nextLine();  // 因为上一个 nextLine 取的是回车前的内容，回车导致成绩不能输入
        // System.out.println("请输入成绩：");
        // score = sc.nextFloat();

        // Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名：");
        name = new Scanner(System.in).nextLine();
        System.out.println("请输入年龄：");
        age = new Scanner(System.in).nextInt();
        System.out.println("请输入性别：");
        sex = new Scanner(System.in).nextLine();
        System.out.println("请输入成绩：");
        score = new Scanner(System.in).nextFloat();

        System.out.printf("name: %s, age: %d, sex: %s, score: %.2f", name, age, sex, score);
    }
}
